import {createRouter, createWebHistory} from 'vue-router'
import Layout from "@/layout/index.vue";

/**
 * isHideSidebar 是否不显示侧边栏
 * title 路由名称
 */
// 动态加载路由页
export const asyncRoutes = [

    {
        path: '/',
        component: Layout,
        redirect: '/index',
        meta: {
            title: '首页',
        },
        children: [
            {
                path: 'index',
                name: 'Index',
                meta: {
                    title: '首页',
                    icon: 'HomeOutlined',
                },
                component: () => import('@/views/home/index'),
            },
            {
                path: '/authority',
                component: Layout,
                name: 'Authority',
                meta: {
                    title: '权限管理',
                    icon: 'SettingOutlined'
                },
                children: [
                    {
                        path: 'menuManage',
                        name: 'MenuManage',
                        meta: {
                            title: '菜单管理',
                        },
                        component: () => import('@/views/authority/menuManage/index'),
                    },
                    {
                        path: 'roleManage',
                        name: 'RoleManage',
                        meta: {
                            title: '角色管理',
                        },
                        component: () => import('@/views/authority/roleManage/index'),
                    },
                    {
                        path: 'userManage',
                        name: 'UserManage',
                        meta: {
                            title: '用户管理',
                        },
                        component: () => import('@/views/authority/userManage/index'),
                    },
                    {
                        path: 'businessManage',
                        name: 'BusinessManage',
                        meta: {
                            title: '事业部管理',
                        },
                        component: () => import('@/views/authority/businessManage/index'),
                    },
                ],
            },
            {
                path: '/finance',
                component: Layout,
                name: 'FinanceManage',
                meta: {
                    title: '财务管理',
                    icon: 'TransactionOutlined'
                },
                children: [
                    {
                        path: 'incomeManage',
                        name: 'IncomeManage',
                        meta: {
                            title: '利润管理',
                        },
                        component: () => import('@/views/finance/incomeManage/index'),
                    },
                    {
                        path: 'lossDetailsManage',
                        name: 'LossDetailsManage',
                        meta: {
                            title: '损益明细管理',
                        },
                        component: () => import('@/views/finance/lossDetailsManage/index'),
                    },
                    {
                        path: 'assetsManage',
                        name: 'AssetsManage',
                        meta: {
                            title: '资产负债管理',
                        },
                        component: () => import('@/views/finance/assetsManage/index'),
                    },
                    {
                        path: 'businessAnalysisManage',
                        name: 'BusinessAnalysisManage',
                        meta: {
                            title: '经营分析管理',
                        },
                        component: () => import('@/views/finance/businessAnalysisManage/index'),
                    },
                    {
                        path: 'quarterlyOperationManage',
                        name: 'QuarterlyOperationManage',
                        meta: {
                            title: '季度经营预算管理',
                        },
                        component: () => import('@/views/finance/quarterlyOperationManage/index'),
                    },
                    {
                        path: 'wordAnalysis',
                        name: 'WordAnalysis',
                        meta: {
                            title: '名词解析',
                        },
                        component: () => import('@/views/finance/wordAnalysis/index'),
                    },
                ],
            },
        ],
    },

]
export const constantRoutes = [
    {
        path: '/login',
        name: 'login',
        component: () => import('@/components/Login/index'),
    },
    ...asyncRoutes
]
const routerHistory = createWebHistory()
const router = createRouter({
    scrollBehavior() {
        // 始终滚动到顶部
        return {top: 0}
    },
    history: routerHistory,
    routes: constantRoutes
})
export default router
